<?php

  session_start();
  include "config.php";
  include "ALcustomer.php";

  if(isset($_SESSION["user"]))
  {
    include "$header";
    include "$body";

	if(isset($_SESSION["cr_surname"]))
    {

?>

<div style="position:absolute; top:0px; left:1px; border:0;">
  <span class="prevPage">Record New Customer Details:Search > </span>
  <span class="prevPage">Record Details > </span>
  <span class="prevPage">Confirm Details > </span>
  <span class="page">Success</span>
</div>
  
<?php

  include "$H_rncd";

  if(isset($_POST["OK"]))
  {
    $_SESSION["c_title"] = $_SESSION["cr_title"];
    $_SESSION["c_surname"] = $_SESSION["cr_surname"];
    $_SESSION["c_given_name"] = $_SESSION["cr_given_name"];
    $_SESSION["c_day"] = $_SESSION["cr_dob_day"];
    $_SESSION["c_month"] = $_SESSION["cr_dob_month"];
    $_SESSION["c_year"] = $_SESSION["cr_dob_year"];
    $_SESSION["c_address"] = $_SESSION["cr_address"];
    $_SESSION["c_pcode"] = $_SESSION["cr_pcode"];
    $_SESSION["c_ph_area"] = $_SESSION["cr_ph_area1"];
    $_SESSION["c_ph_no"] = $_SESSION["cr_ph_no1"];

    unset($_SESSION["cs_surname"]);
    unset($_SESSION["cs_given_name"]);
    unset($_SESSION["cs_dob_day"]);
    unset($_SESSION["cs_dob_month"]);
    unset($_SESSION["cs_dob_year"]);
    unset($_SESSION["cs_address"]);
    unset($_SESSION["cs_pcode"]);
    unset($_SESSION["cs_ph_area1"]);
    unset($_SESSION["cs_ph_no1"]);

    unset($_SESSION["cr_title"]);
    unset($_SESSION["cr_surname"]);
    unset($_SESSION["cr_given_name"]);
    unset($_SESSION["cr_dob_day"]);
    unset($_SESSION["cr_dob_month"]);
    unset($_SESSION["cr_dob_year"]);
    unset($_SESSION["cr_address"]);
    unset($_SESSION["cr_pcode"]);
    unset($_SESSION["cr_ph_area1"]);
    unset($_SESSION["cr_ph_no1"]);
    unset($_SESSION["cr_ph_area2"]);
    unset($_SESSION["cr_ph_no2"]);
    unset($_SESSION["cr_card_type1"]);
    unset($_SESSION["cr_card_name1"]);
    unset($_SESSION["cr_card_no1_1"]);
    unset($_SESSION["cr_card_no1_2"]);
    unset($_SESSION["cr_card_no1_3"]);
    unset($_SESSION["cr_card_no1_4"]);
    unset($_SESSION["cr_card_expiry_month1"]);
    unset($_SESSION["cr_card_expiry_year1"]);
    unset($_SESSION["cr_card_type2"]);
    unset($_SESSION["cr_card_name2"]);
    unset($_SESSION["cr_card_no2_1"]);
    unset($_SESSION["cr_card_no2_2"]);
    unset($_SESSION["cr_card_no2_3"]);
    unset($_SESSION["cr_card_no2_4"]);
    unset($_SESSION["cr_card_expiry_month2"]);
    unset($_SESSION["cr_card_expiry_year2"]);

    echo "<SCRIPT language='Javascript'>";
    echo "  window.location.href = 'main.php'";
    echo "</SCRIPT>";
  }

  echo "Details for Customer <b>".$_SESSION["cr_given_name"]." ".$_SESSION["cr_surname"]." [".$_SESSION["customerID"]."]</b> has been recorded successfully.";

?>

<p>
<FORM name="ok" action="" method="post">
<input class="submit_off" type="submit" value="OK" name="OK" onmouseover="className='submit_on'" onmouseout="className='submit_off'" />
</FORM>
</BODY>

<?php
    }
    else
    {
      echo "<SCRIPT language='Javascript'>";
      echo "  window.location.href = 'recordNewCustomerDetails.php';";
      echo "</SCRIPT>";
    }
    include "$footer";
  }
  else
  {
    session_destroy();
    echo "<SCRIPT language='Javascript'>";
    echo "  parent.window.location.href = 'index.php';";
    echo "</SCRIPT>";
  }

?>